#include <tchar.h>
#include "Drawer.h"
#include "Car.h"
#include "Land.h"
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 800

static Car *mycar;
static Drawer *mydraw;
static Land *myland;
//static Point direction = {0,0,1};
//static Point look = {100,100,100};
//static Point at = {0,0,0};
//static Point up = {0,1,0};

void keyboard(unsigned char key, int x, int y)
{
	switch (key)
	{
	case 'w':
		mycar->Forward();
		break;
	case 'a':
		mycar->TurnLeft();
		break;
	case 's':
		mycar->Back();
		break;
	case 'd':
		mycar->TurnRight();
		break;
	default:
		break;
	}
	::glutPostRedisplay();
}

void display()
{
	mydraw->Draw();
}

int _tmain(int argc, _TCHAR* argv[])
{
	glutInit(&argc,(char**)argv);
	glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
	glutInitWindowPosition(0,0);
	glutInitWindowSize(SCREEN_WIDTH,SCREEN_HEIGHT);
	glEnable(GL_TEXTURE_2D);
	glutCreateWindow("CoolCar");

	mycar = new Car("CPoints.txt","Cfaces.txt", "Textures.txt", "TextureIndex.txt");

	myland = new Land;

	mydraw = new Drawer;

	mydraw->PushSprite(mycar);
	mydraw->PushSprite(myland);

	glutKeyboardFunc(&keyboard);
	glutDisplayFunc(&display);
	glutMainLoop();
	return 0;
}